import os
class MyFile:
    # def __init__(self, path):
    #     self.path = path

    # 得到该目录下所有文件(包括子目录)
    def getAllFiles(self, path):
        all = os.listdir(path)
        files = []
        for name in all:
            full_name = os.path.join(path, name)
            if os.path.isdir(full_name):
                ls = self.getAllFiles(full_name)
                files.extend(ls)
            else:
                files.append(full_name)
        return files

        # 得到该目录下所有文件数量(包含子目录)

    def getAllFileNum(self, path):
        all = os.listdir(path)
        num = 0
        for name in all:
            full_name = os.path.join(path, name)
            if os.path.isdir(full_name):
                num += self.getAllFileNum(full_name)
            else:
                num += 1
        return num

    # 得到该目录下所有目录(包括子目录)
    def getAllFolders(self, path):
        all = os.listdir(path)
        folders = []
        for name in all:
            full_name = os.path.join(path, name)
            if os.path.isdir(full_name):
                #print(full_name)
                ls = self.getAllFolders(full_name)
                folders.append(full_name)
                folders.extend(ls)
        return folders

    # 得到该目录下所有目录数量(包含子目录)
    def getAllFolderNum(self, path):
        all = os.listdir(path)
        num = 0
        for name in all:
            full_name = os.path.join(path, name)
            if os.path.isdir(full_name):
                num += self.getAllFolderNum(full_name)
                num += 1
        return num


